import * as dotenv from 'dotenv';
import * as fs from 'fs';

export class ConfigService {
  private readonly envConfig: { [key: string]: string };
  private readonly runtimeConfig: { [key: string]: any };

  constructor(filePath: string) {
    this.envConfig = dotenv.parse(fs.readFileSync(filePath));
    this.runtimeConfig = {};
  }

  get(key: string, def: string): string {
    return this.envConfig[key] || def;
  }

  getRuntime(key: string): any {
    return this.runtimeConfig[key];
  }

  setRuntime(key: string, value: any): void {
    this.runtimeConfig[key] = value;
  }
}
